package com.azunitech.jms.common.domains;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class PartsEntity implements Serializable {

	private static final long serialVersionUID = 1L;
	private String m_PartNumber;
	private Map<String, LocationVo> m_Locations = new HashMap<String, LocationVo>();
	
	public PartsEntity( String partNumber){
		this.m_PartNumber = partNumber;
	}

	public void addLocation( LocationVo location ){
		String code = location.getLocationCode();
		if ( this.m_Locations.containsKey(code)){
			LocationVo temp = this.m_Locations.get(code);
			temp.increaseQuantity(location.getQuantity());
		}
		else {
			this.m_Locations.put(location.getLocationCode(), location);
		}
	}
	
	
	public String toString(){
		StringBuffer buffer = new StringBuffer();
		buffer.append("Part Number= " + this.m_PartNumber).append(" ");
		buffer.append("locations: " + Arrays.toString(m_Locations.values().toArray()));
		return buffer.toString();
	}
}
